package com.megvii.koala.components;

import android.view.View;
import android.widget.TextView;

/**
 * Created by linyue on 15/12/25.
 */
public class UploadImageView
{
    public static final String UPLOADING = "上传中";
    public static final String UPLOAD_FAIL = "上传失败";

    private ImageViewEx imageView;

    private TextView textView;

    public UploadImageView(ImageViewEx imageView, TextView textView)
    {
        super();
        this.imageView = imageView;
        this.textView = textView;
    }

    public void loadImage(String url)
    {
        imageView.loadImage(url);
    }


    public void setUploadStatus(UploadStatus status)
    {
        switch (status)
        {
            case UPLOADING:
                textView.setVisibility(View.VISIBLE);
                textView.setText(UPLOADING);
                break;
            case UPLOAD_SUCCESS:
                textView.setVisibility(View.GONE);
                break;
            case UPLOAD_FAIL:
                textView.setVisibility(View.VISIBLE);
                textView.setText(UPLOAD_FAIL);
                break;
        }
    }

    public enum UploadStatus
    {
        UPLOADING,
        UPLOAD_SUCCESS,
        UPLOAD_FAIL
    }
}
